package com.wlanauth.web.core.tree;



import java.util.ArrayList;
import java.util.List;

public class TreeNode implements  Cloneable {

	

	private static final long serialVersionUID = 1L;
	
	private String id;
	private String text;
	private String parentId;
	private String href;
	private String xtype;
	private List<TreeNode> children;
	
	private String iconCls;
	private boolean leaf;
	private String resourceCode;
	private Object attr;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getHref() {
		return href;
	}

	public void setHref(String href) {
		this.href = href;
	}

	public List<TreeNode> getChildren() {
		return children;
	}

	public void setChildren(List<TreeNode> children) {
		this.children = children;
	}

	public boolean isLeaf() {
		return leaf;
	}

	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getXtype() {
		return xtype;
	}

	public void setXtype(String xtype) {
		this.xtype = xtype;
	}

	public Object getAttr() {
		return attr;
	}

	public void setAttr(Object attr) {
		this.attr = attr;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}
	

	public String getResourceCode() {
		return resourceCode;
	}

	public void setResourceCode(String resourceCode) {
		this.resourceCode = resourceCode;
	}

	/**
	 * 克隆（浅拷贝）
	 * @return
	 */
	public TreeNode cloneSelf(){
		try {
			TreeNode node = (TreeNode) super.clone();
			if(node.children!=null){
				ArrayList<TreeNode> childrens = new ArrayList<TreeNode>();
				for(TreeNode n:this.children){
					childrens.add(n.cloneSelf());
				}
				node.setChildren(childrens);
			}
			return node;
		} catch (CloneNotSupportedException e) {
			throw new RuntimeException("clone treenode exception:"+e.getMessage(),e);
		}
	}

}
